#pragma once
#pragma warning( disable : 4290 )

#include "Definitions.h"
#include "SenetBoardDraft.h"
#include "SenetHeuristics.h"
#include "SenetMove.h"
#include "SticksProbability.h"
#include "CommonAlgorithmsDefs.h"

 class Expectimax
 {
 public:
	 
	 //C'tor
	// Expectimax(SenetHeuristics& heuristic);

	 //initialize the algorithm
	 void Init(const SenetPlayerExt* owner , int gameStickNum);

	 //initialize with heuristic params
	 void InitHeuristicParams(const float* heuristicParams);
	 
	 //Assignment operator
	 Expectimax& Expectimax::operator=(const Expectimax& e);

	 //return expectimax score for the given board
	 SenetMove scoreExpectimax(SenetBoardDraft& boardOrig, int depth, const GameTimer& timer ,
								bool checkTime , Definitions::PlayerColor myColor, int stickNum) throw(Exception);
	 
	//TODO: debug
	 float FinalBoardScore()
	 {
		 float res = m_FinalBoardScore;
		 return res;
	 }
	 
	 float m_FinalBoardScore;
 private:
	 SenetHeuristics m_heuristic;
	 int m_gameStickNum;
	 int m_gameTwoThirdStickNum;
	 SticksProbability m_probabilities;

	 //functions:
	 
	 Score chanceSearch(SenetBoardDraft& board, int depth, const GameTimer& timer, bool checkTime ,
						Definitions::PlayerColor currentPlayer, int stickNum ,  
						NodeType nodeType , NodeType nextTurn) throw(Exception);
	 
	 void minimax(Score& res , SenetBoardDraft& board, int depth, const GameTimer& timer,  bool checkTime , 
					Definitions::PlayerColor currentPlayer, int stickNum , NodeType nodeType) throw (Exception);
	 
	 void expectimax(Score& res, SenetBoardDraft &board, int depth, const GameTimer& timer, bool checkTime , 
						Definitions::PlayerColor nextPlayer, NodeType nodeType) throw (Exception);

// 	 inline void undoMoves(vector<SenetBoardDraftMove>& movesPerformed, SenetBoardDraft& board , Definitions::PlayerColor currentPlayer)
// 	 {
// 		 for(int i=movesPerformed.size()-1; i>=0 ; i--)
// 		 {
// 			 board.undoMove(movesPerformed[i].dest() , movesPerformed[i].start(), currentPlayer);
// 		 }
// 	 }
 };